package homework;

import java.util.Scanner;

public class homework1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int choice1,choice2 = 0;
        boolean judgeEnd = true;
        do {
            System.out.println("欢迎使用职工公司计算系统!");
            System.out.println("请选择要执行的操作:>\n1.单个职工工资计算\n2.多个职工工资运算\n3.退出");
            choice1 = sc.nextInt();
            switch (choice1) {
                case 1: {
                    System.out.println("请输入职工名称");
                    String name = sc.next();
                    System.out.println("请输入职工性别");
                    boolean sex = sc.nextBoolean();
                    int[] income = new int[3];
                    System.out.println("请输入基本工资");
                    income[0] = sc.nextInt();
                    System.out.println("请输入津贴");
                    income[1] = sc.nextInt();
                    System.out.println("请输入奖金");
                    income[2] = sc.nextInt();
                    int sumIncome = 0;
                    for (int i : income)
                        sumIncome += i;
                    System.out.println("名字:>" + name + "\t性别:>" + (sex ? "男" : "女") + "\t总收入:>" + sumIncome);
                    break;
                }
                case 2: {
                    int numPeo = sc.nextInt();
                    String[] name = new String[numPeo];
                    boolean[] sex = new boolean[numPeo];
                    int[][] income = new int[3][numPeo];
                    int[] sumIncome = new int[numPeo];
                    for (int i = 0; i < numPeo; i++) {
                        System.out.println("请输入职工" + i + "名称");
                        name[i] = sc.next();
                        System.out.println("请输入职工" + i + "性别");
                        sex[i] = sc.nextBoolean();
                        System.out.println("请输入职工" + i + "基本工资");
                        income[i][0] = sc.nextInt();
                        System.out.println("请输入职工" + i + "津贴");
                        income[i][1] = sc.nextInt();
                        System.out.println("请输入职工" + i + "奖金\n\n");
                        income[i][2] = sc.nextInt();
                        sumIncome[i] = 0;
                        for (int j : income[i])
                            sumIncome[i] += j;
                    }
                    for (int i = 0; i < numPeo; i++) {
                        System.out.println("名字:>" + name[i] + "\t性别:>" +
                                (sex[i] ? "男" : "女") + "\t总收入:>" + sumIncome[i]);
                    }
                    break;
                }
                case 3: {
                    System.out.println("退出");
                    judgeEnd = false;
                    break;
                }
                default:
                    System.out.println("你输入的数字不在选项范围内");
            }
            System.out.println("是否继续？ 1.继续 2.退出");
            for (int i = 0; i < 1;) {
                choice2 = sc.nextInt();
                if(choice2 == 1 || choice2 == 2)
                    i++;
                else
                    System.out.println("选择错误，请重新选择");
            }
            if(choice2 == 2)
                judgeEnd = false;
        } while (judgeEnd);
    }
}
